#!/usr/bin/env node

const log = console.log;
//timer1启动后，5s结束启动timer2;
//timer2定时执行5次退出

let timer1,timer2,count = 1;

timer1 = setInterval(loop1,500);

setTimeout(()=>{
  log('timer1结束');
  clearInterval(timer1);
  log('clear timer1 ;start timer2');
  timer2 = setInterval(loop2,500);
},5000);

function loop1(){
  log('#1 will loop!');
}

function loop2(){
  log('#2 will loop！');
  if(count++ >= 5){
    count = 0;
    log('over!');
    global.clearInterval(timer2);
  }
}



console.log('hello','world');
